package com.ynunicom.midplatform.sys.user;

import com.ynunicom.midplatform.common.persistence.entity.AbstractIdEntity;
import com.ynunicom.midplatform.sys.role.SysRole;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.util.List;

/**
 * 系统用户表
 *
 * @author duwei
 */
@Entity
@Table(name = "sys_user")
@Getter
@Setter
public class SysUser extends AbstractIdEntity {

    /**
     * 帐号
     */
    @Column(unique = true)
    private String loginName;
    /**
     * 名称（昵称或者真实姓名，不同系统不同定义）
     */
    private String name;
    private String password;
    private String salt;
    /**
     * /用户状态,0:创建未认证（比如没有激活，没有输入验证码等等）--等待验证的用户 , 1:正常状态,2：用户被锁定
     */
    private byte state;

    @Column(unique = true)
    private String phoneNo;

    @ManyToMany(fetch = FetchType.EAGER)
    @JoinTable(name = "SysUserRole", joinColumns = {@JoinColumn(name = "userId")}, inverseJoinColumns = {@JoinColumn(name = "roleId")})
    private List<SysRole> roleList;
}
